<template>
	<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
		<swiper-item style="height: 300px;" v-for="(item, index) in data" :key="index">
			<view class="swiper-item">
				<image style="width: 100%;" :src="item.img" mode=""></image>
			</view>
		</swiper-item>
	</swiper>
	
  <view class="list">
    <view class="title">热映电影</view>
    <view class="item" v-for="(item, index) in data" :key="index" @tap="toDetails(item.id)">
      <view class="pic">
        <image :src="item.img" mode="aspectFill"></image>
      </view>
      <view class="content">
        <view class="name">{{ item.nm }}</view>
        <view class="cat">{{ item.cat }}</view>
        <view class="dir">导演:{{ item.dir }}</view>
        <view class="msg">{{ item.desc }}</view>
        <view class="showtime">上映时间: {{ item.pubDesc }}</view>
        <view class="info2">
          <view class="sc">评分: {{ item.sc }}</view>
          <view class="wish">想看: {{ item.wish }}人</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
	import {
		onLoad
	} from "@dcloudio/uni-app"
	import {
		ref
	} from 'vue'
	import {
		CONFIG
	} from "../../utils/config"
	
	import {
		userStore
	} from "../../store/userStore.js"
	const store = userStore()
	
	import {data} from "/utils/data.js"
	
	// let store = userStore()

	// onLoad(() => {
	// 	gethotMovieList()
	// })

	// async function getHotMoveList() {
	// 	let res = await uni.$get("https://wx.maoyan.com/mmdb/movie/v2/list/hot.json")
	// 	console.log(res)
	// }
	
	function toDetails(id){
	  uni.navigateTo({
	    url: "/pages/hotMovieDetails/hotMovieDetails?movieId=" +id
	  })
	}
</script>

<style>
	body{
		background-color: gainsboro;
	}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Arial', sans-serif;
  background-color: #f5f5f5;
  color: #333;
}

.list {
  padding: 16px;
}

.title {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 16px;
}
.item {
  display: flex;
  background-color: #fff;
  padding: 16px;
  margin-bottom: 16px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pic {
  width: 120px;
  height: 160px;
  margin-right: 16px;
  border-radius: 8px;
  overflow: hidden;
}

.pic image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.content {
  flex: 1;
}

.name {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 8px;
}

.cat, .dir, .msg, .act, .showtime {
  font-size: 14px;
  margin-bottom: 8px;
}

.info2 {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
}

.sc, .wish {
  margin-bottom: 0;
}
.rating-bar {
  width: 100px;
  height: 10px;
  background: linear-gradient(to right, #ff6b08, #ff6b08 50%, #ccc 50%);
  border-radius: 5px;
  margin-top: 8px;
  position: relative;
}

.rating-bar::before {
  content: attr(data-rating);
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #fff;
  background-color: #333;
  padding: 2px 8px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
</style>